package job.work.domain.response;

import com.google.common.collect.ImmutableMap;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;


/**
 * Created by admin on 2018/3/5.
 */
@ToString
public enum AuthCode implements ResultCode {
    AUTH_USERNAME_NONE(false, 23001, "请输入账号！"),
    AUTH_PASSWORD_NONE(false, 23002, "请输入密码！"),
    AUTH_VERIFYCODE_NONE(false, 23003, "请输入验证码！"),
    AUTH_ACCOUNT_NOTEXISTS(false, 23004, "账号不存在！"),
    AUTH_CREDENTIAL_ERROR(false, 23005, "账号或密码错误！"),
    AUTH_LOGIN_ERROR(false, 23006, "登陆过程出现异常请尝试重新操作！"),
    AUTH_LOGIN_APPLYTOKEN_FAIL(false, 23007, "申请令牌失败！"),
    AUTH_LOGIN_TOKEN_SAVEFAIL(false, 23008, "存储令牌失败！"),
    AUTH_LOGIN_TOKEN_DISABLE(false, 23009, "该账户已被禁用！"),
    AUTH_LOGIN_TOKEN_TIME(false, 23010, "令牌已过期！"),
    AUTH_LOGIN_TOKEN_ILLEGAL(false, 23011, "非法令牌！"),
    PASSWORD_ILLEGAL(false, 23012, "两次密码不一致！"),
    PASSWORD_ORIGINAL_ILLEGAL(false, 23013, "原密码错误！"),
    PASSWORD_ORIGINAL_LENGTH(false, 23014, "密码不能小于6位！"),
    ROLE_ERROR(false, 23015, "角色不存在！"),
    AUTH_MOBILE_ERROR(false, 23016, "手机号不存在！"),
    AUTH_VERIFYCODE_ERROR(false, 23017, "验证码错误！"),
    AUTH_WEIXIN_LOGIN_ERROR(false, 23018, "微信授权登录错误！"),
    AUTH_WEIXIN_PAY_ERROR(false, 23019, "微信支付错误！"),
    AUTH_WEIXIN_PAY_AUTHORIZE(false, 23020, "请先授权微信登录在发起支付"),
    AUTH_WALLET_NOT_ENOUGH(false, 23021, "钱包余额不足,请充值"),
    AUTH_ADDR_UPDATE_ERROR(false, 23022, "设置默认地址失败"),
    AUTH_PHONE_SAME(false, 23023, "新号码与当期绑定号码一致, 无需修改"),
    AUTH_PHONE_HAD_EXISTS(false, 23024, "号码已经被其他账号绑定, 不能再绑定"),
    COMMISSION_WITHDRAWAL_NOT_ENOUGH(false, 23025, "提现金额大于总金额"),
    MINIMUM_NUMBER_OF_MERCHANTS_TO_PROMOTE(false, 23026, "提现失败, 不满足推广最小商家个数"),
    MINIMUM_WITHDRAWAL_AMOUNT(false, 23027, "提现失败, 不满足提现最小金额"),
    AUTH_IS_NOT_CLERK(false, 23028, "非业务员"),
    NOT_LESS_ONE(false, 23029, "提现金额不能少于1元"),
    WEIXIN_WITHDRAW_FAIL(false, 23030, "微信提现失败"),
    PAY_PWD_ERROR(false, 23031, "支付密码错误"), MSG_ERROR(false, 23032, "没有找到短信类型");


    //操作代码
    @ApiModelProperty(value = "操作是否成功", example = "true", required = true)
    boolean success;

    //操作代码
    @ApiModelProperty(value = "操作代码", example = "22001", required = true)
    int code;
    //提示信息
    @ApiModelProperty(value = "操作提示", example = "操作过于频繁！", required = true)
    String message;

    private AuthCode(boolean success, int code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    private static final ImmutableMap<Integer, AuthCode> CACHE;

    static {
        final ImmutableMap.Builder<Integer, AuthCode> builder = ImmutableMap.builder();
        for (AuthCode commonCode : values()) {
            builder.put(commonCode.code(), commonCode);
        }
        CACHE = builder.build();
    }

    @Override
    public boolean success() {
        return success;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }
}
